package com.oa.lms.apps.business.user.impl;

import java.util.List;

import com.oa.lms.apps.business.user.ISectionInfoService;
import com.oa.lms.apps.constants.IDEDStatus;
import com.oa.lms.apps.dao.user.ISectionInfoDao;
import com.oa.lms.apps.entity.user.SectionInfoValue;

public class SectionInfoServiceImpl implements ISectionInfoService {
	
	private ISectionInfoDao sectionInfoDao;
	
	private SectionInfoValue sectionInfoValue;

	@Override
	public Integer add(String sectionName) {
		sectionInfoValue.setSectionName(sectionName);
		sectionInfoValue.setStatus(IDEDStatus.ENABLE);
		return sectionInfoDao.add(sectionInfoValue);
	}

	@Override
	public void modify(Integer sectionId, String sectionName) {
		sectionInfoValue = this.queryBySectionId(sectionId);
		sectionInfoValue.setSectionName(sectionName);
		sectionInfoDao.modify(sectionInfoValue);
	}
	
	@Override
	public void delete(Integer sectionId){
		sectionInfoValue = this.queryBySectionId(sectionId);
		sectionInfoValue.setStatus(IDEDStatus.DELETE);
		sectionInfoDao.modify(sectionInfoValue);
	}

	@Override
	public void toDisable(Integer sectionId) {
		sectionInfoValue = this.queryBySectionId(sectionId);
		sectionInfoValue.setStatus(IDEDStatus.DISABLE);
		sectionInfoDao.modify(sectionInfoValue);
	}

	@Override
	public void toEnable(Integer sectionId) {
		sectionInfoValue = this.queryBySectionId(sectionId);
		sectionInfoValue.setStatus(IDEDStatus.ENABLE);
		sectionInfoDao.modify(sectionInfoValue);
	}

	@Override
	public SectionInfoValue queryBySectionId(Integer sectionId) {
		return sectionInfoDao.queryBySectionId(sectionId);
	}

	@Override
	public List<SectionInfoValue> querySectionInfo(String sectionName, Integer status) {
		if(sectionName != null)
			sectionInfoValue.setSectionName(sectionName);
		if(status != null)
			sectionInfoValue.setStatus(status);
		return sectionInfoDao.querySectionInfo(sectionInfoValue);
	}
	
	
	//Getter and Setter

	public ISectionInfoDao getSectionInfoDao() {
		return sectionInfoDao;
	}

	public void setSectionInfoDao(ISectionInfoDao sectionInfoDao) {
		this.sectionInfoDao = sectionInfoDao;
	}

	public SectionInfoValue getSectionInfoValue() {
		return sectionInfoValue;
	}

	public void setSectionInfoValue(SectionInfoValue sectionInfoValue) {
		this.sectionInfoValue = sectionInfoValue;
	}

}
